<?php

namespace Database\Seeders;

use App\Models\Country;
use App\Models\Language;
use App\Models\Locale;
use Illuminate\Database\Seeder;

class LocaleSeeder extends Seeder
{
  public function run()
  {
    // Italian
    $italian = Language::where('iso_639_1', 'it')->first();
    $italy = Country::where('iso_639_1', 'IT')->first();
    $firstLocale = new Locale();
    $firstLocale->code = 'it_IT.UTF-8';
    $firstLocale->name = 'Italiano';
    $firstLocale->language_id = $italian->id;
    $firstLocale->country_id = $italy->id;
    $firstLocale->save();
    // American English
    $english = Language::where('iso_639_1', 'en')->first();
    $america = Country::where('iso_639_1', 'US')->first();
    $secondLocale = new Locale();
    $secondLocale->code = 'en_US.UTF-8';
    $secondLocale->name = 'Inglese Americano';
    $secondLocale->language_id = $english->id;
    $secondLocale->country_id = $america->id;
    $secondLocale->save();
    // British English
    $unitedKingdom = Country::where('iso_639_1', 'GB')->first();
    $thirdLocale = new Locale();
    $thirdLocale->code = 'en_GB.UTF-8';
    $thirdLocale->name = 'Inglese Britannico';
    $thirdLocale->language_id = $english->id;
    $thirdLocale->country_id = $unitedKingdom->id;
    $thirdLocale->save();
  }
}
